home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / rexx / lookupword.epxx < prev    next >
Text File  |  1996-07-28  |  3KB  |  92 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /*     File : LookUpWord.epxx                                           */
  4. /*   Author : Martin Reddy                                              */
  5. /*     Date : 28/8/92                                                   */
  6. /*  Purpose : An ARexx script used to control the text editor EdWord    */
  7. /*     Note : This is part of the Spell Checking facility of EdWord     */
  8. /* Function : This script prompts the user for a string and then checks */
  9. /*            to see if this string is in the dictionary. The user is   */
  10. /*            informed of the result and, if the word was not found,    */
  11. /*            then upto 4 possible suggestions are made.                */
  12. /*  Updates : [28/8/96] optionally add words to dictionary if not found */
  13. /*                                                                      */
  14. /************************************************************************/
  15.  
  16.  
  17.     /*-------------- Nothing To Change Below Here -----------*/
  18.  
  19.     HOST = ADDRESS()
  20.     ADDRESS VALUE HOST
  21.  
  22.     OPTIONS RESULTS
  23.  
  24.     /********** Make sure that the ISpell process is up *********/
  25.  
  26.     IF ~SHOW( PORTS, 'IRexxSpell' ) THEN DO
  27.         Message "Loading Dictionary..."
  28.         ADDRESS COMMAND 'run <nil: >nil: EdSpell:ISpell/ispell -r >nil: <nil:'
  29.         ADDRESS COMMAND 'EdSpell:ISpell/WaitForPort IRexxSpell'
  30.         IF RC ~= 0 THEN DO
  31.             Inform "Could Not Start ISpell Process|Spell Check Aborted!"
  32.             Message ""
  33.             EXIT
  34.         END
  35.     END
  36.  
  37.     /**************** Get a Word From The User *****************/
  38.  
  39.     GetInput "Enter Word To Look Up In Dictionary :"
  40.     IF RESULT ~= "RESULT" THEN DO
  41.  
  42.         /**************** Now check the word ****************/
  43.  
  44.         SEARCHWORD = COMPRESS( UPPER(RESULT), '~`,./<>?;:"[]{}!@#$%^&*()+|=\- ' )
  45.         ADDRESS "IRexxSpell" CHECK SEARCHWORD
  46.         WORD = RESULT
  47.  
  48.         IF WORD == "*" THEN DO
  49.             Inform SEARCHWORD" Found In Dictionary|Word Is Spelt Correctly"
  50.             EXIT
  51.         END; ELSE IF LEFT(WORD,1) == "+" THEN DO
  52.             PARSE VAR WORD DUMMY ROOT
  53.             Choice SEARCHWORD" Is A Valid Combination|But Is Not In Dictionary|(Root Word Is "ROOT")@@Okay|Add Word"
  54.         END; ELSE IF LEFT(WORD,1) == "&" THEN DO
  55.             PARSE VAR WORD DUMMY SUGA SUGB SUGC SUGD SUGE
  56.  
  57.             SUG = "|1) "SUGA
  58.             IF (SUGB ~= "END") & (SUGB ~= "") & (SUGB ~= "SUGB") THEN DO
  59.                 SUG = SUG||"|2) "||SUGB
  60.             END
  61.             IF (SUGC ~= "END") & (SUGC ~= "") & (SUGC ~= "SUGC") THEN DO
  62.                 SUG = SUG||"|3) "||SUGC
  63.             END
  64.             IF (SUGD ~= "END") & (SUGD ~= "") & (SUGD ~= "SUGD") THEN DO
  65.                 SUG = SUG||"|4) "||SUGD
  66.             END
  67.  
  68.             Choice SEARCHWORD" Not In Dictionary|Possible Suggestions Are:|"||SUG||"@@Okay|Add Word"
  69.         END; ELSE DO
  70.             Choice SEARCHWORD" Not In Dictionary|No Possible Suggestions Found@@Okay|Add Word"
  71.         END
  72.  
  73.         IF RC == 0 THEN DO
  74.             CALL AddWord( SEARCHWORD )
  75.         END
  76.  
  77.     END
  78.  
  79.     EXIT
  80.  
  81.     /************ PROCEDURE: "AddWord(word)" ************/
  82.  
  83.     AddWord: PROCEDURE
  84.     PARSE ARG THEWORD
  85.         Choice "Please Confirm The Addition of|"||THEWORD||" To The Dictionary.@@Add Word|Cancel"
  86.         IF RC ~= 0 THEN DO
  87.             ADDRESS "IRexxSpell" ADD THEWORD
  88.         END
  89.     RETURN
  90.  
  91.  
  92.